# frozen_string_literal: true
class V1::SessionController < V1::ApplicationController

  def create
    raise CommonError::CustomMessageError.new('registration_id 是空的') if params[:registration_id].blank?

    @current_editor = Editor.where(telephone: params[:telephone]).first.try(:authenticate, params[:password])

    raise CommonError::CustomMessageError.new('用户名或者密码错误') if @current_editor.blank?

    @current_editor.registration_id = params[:registration_id]

    @current_editor.save

    @village = @current_editor.village
  end

end
